package ar.edu.itba.it.cg.grupo01.impl.shape.shader;

import java.awt.Color;

import javax.vecmath.Point2f;
import javax.vecmath.Point3f;

import ar.edu.itba.it.cg.grupo01.api.shape.Shape;

public class OrganicShader extends PerlinShader {

	public OrganicShader(Color noNoise, Color fullNoise) {
		super(noNoise, fullNoise);
	}

	@Override
	public float getNoise(Shape shape, Point3f intersectionPoint) {
		Point2f uv = shape.getUVCoordinates(intersectionPoint);
		uv.scale(50);
		float noise = PerlinNoise.noise2(uv.x, uv.y);
		return (float) (noise - Math.floor(noise));
	}

	@Override
	protected float getTurbulenceFunction(Point3f p, float noise, float frequency, int times) {
		return (float) ((Math.cos(frequency*noise)+Math.sin(frequency*noise)));
	}

}
